<?php
use think\facade\Route;

use app\common\model\Category as CategoryModel;

$CategoryModel = new CategoryModel();
$cate_res = $CategoryModel
//    ->where('parentid','=',0)
    ->where('is_open','=',1)
    ->order('orderid asc')->select();

//Route::rule('lists-:catid', 'index/lists');
//Route::rule('listsdetail-:catid-:id', 'index/detail');
//
//Route::rule('policy-:catid', 'index/lists');
//Route::rule('policydetail-:catid-:id', 'index/detail');
//
//Route::rule('notice-:catid', 'index/lists');
//Route::rule('noticedetail-:catid-:id', 'index/detail');
//
//Route::rule('info-:catid', 'index/lists');
//Route::rule('infodetail-:catid-:id', 'index/detail');

foreach ($cate_res as $k=>$v){
    if($v['htmlname']){
        Route::rule($v['htmlname'], 'index/'.$v['htmlname']);
        Route::rule($v['htmlname'].'detail', 'index/detail');
    }else{
        Route::rule($v['module'].'-:catid', 'index/lists');
        Route::rule($v['module'].'detail-:catid-:id', 'index/detail');
    }
}

//Route::rule('<catdir>-<catid>-<page>','index/lists', '*',[],['catdir'=>'\w+','catid'=>'\d+','page'=>'\d+']);
//Route::rule('<catdir>-<catid>-<id>-<page>','index/detail', '*',[],['catdir'=>'\w+','catid'=>'\d+','id'=>'\d+','page'=>'\d+']);